package org.vincen.helloworld.jaxb;

import java.util.Date;
import java.util.Map;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement(name="book")
////对xml标签排序，可以用XmlType(propOrder={})
//@XmlType(propOrder={"author", "name", "isbn"})
//使用ALPHABETICAL是以字母表排序，UNDEFINED是不排序，此注解可以用在包和父类上
//@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
//@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class Book {
	private String bookName;
	private String author;
	private float price;
	private Map<String, String> editors; 
	private Date publishDate;
	private String language;
	
	//一般将注解用在get方法上
	//change the tag name to "title"
	@XmlElement(name="title")
	public String getBookName() {
		return bookName;
	}
	public void setBookName(String bookName) {
		this.bookName = bookName;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public float getPrice(){
		return price;
	}
	public void setPrice(float price){
		this.price = price;
	}

	@XmlJavaTypeAdapter(MapAdapter.class)
	public Map<String, String> getEditors() {
		return editors;
	}
	public void setEditors(Map<String, String> editors) {
		this.editors = editors;
	}
	public Date getPublishDate(){
		return publishDate;
	}
	public void setPublishDate(Date publishDate){
		this.publishDate = publishDate;
	}
	// 不转换此属性
//	@XmlTransient
	//XmlAttribute用在Book标签的属性
	@XmlAttribute(name="lang")
	public String getLanguage() {
		return language;
	}
	public void setLanguage(String language) {
		this.language = language;
	}

}
